package org.transformatorhuis.unix.server;

import org.transformatorhuis.unix.server.nativeos.CommandLineLinux;
import org.transformatorhuis.unix.server.nativeos.CommandLineMacOSX;
import org.transformatorhuis.unix.server.nativeos.CommandLineSolaris;

/**
 * User: Olivier Van Acker
 * Date: Mar 15, 2010
 */
public class CommandLineFactory {

    public static CommandLine getCommandLine() {

        String os = System.getProperty("os.name");
        if("Linux".equals(os))
            try {
                return new CommandLineLinux();
            } catch (Exception e) {
                throw new UnsupportedOperationException("Error creating Linux command line: " + e.toString());
            }
        if("SunOS".equals(os))
            try {
                return new CommandLineSolaris();
            } catch (Exception e) {
                throw new UnsupportedOperationException("Error creating Solaris command line: " + e.toString());
            }
        if("Mac OS X".equals(os))
            try {
                return new CommandLineMacOSX();
            } catch (Exception e) {
                throw new UnsupportedOperationException("Error creating Mac OS X command line: " + e.toString());
            }

        throw new UnsupportedOperationException("Unsupported Operating System "+os);

    }
}
